﻿using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Security;

namespace StudentInfoSystem.Core.Models
{
    public class UserAccount : INotifyPropertyChanged
    {
        public UserAccount()
        {
            // 默认构造函数
        }
        private bool _isAdmin =false;
        public bool IsAdmin
        {
            get => _isAdmin;
            set
            {
                _isAdmin = value;
                OnPropertyChanged();
            }
        }
        public UserAccount(string username, string email, string passwordHash, bool rememberMe)
        {
            Username = username;
            Email = email;
            PasswordHash = passwordHash;
            RememberMe = rememberMe;
        }

        private string _username;
        public string Username
        {
            get => _username;
            set
            {
                _username = value;
                OnPropertyChanged();
            }
        }

        // 注意：密码不会直接存储，只存储加密后的哈希值
        private string _passwordHash;
        public string PasswordHash
        {
            get => _passwordHash;
            set
            {
                _passwordHash = value;
                OnPropertyChanged();
            }
        }

        private string _email;
        public string Email
        {
            get => _email;
            set
            {
                _email = value;
                OnPropertyChanged();
            }
        }

        private bool _rememberMe;
        public bool RememberMe
        {
            get => _rememberMe;
            set
            {
                _rememberMe = value;
                OnPropertyChanged();
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}